package com.itheima.iterator;

import java.util.List;

/**
 * @author zzw
 * @date 2025/10/26
 * @description 迭代器模式（具体迭代器类）
 */
public class StudentIteratorImpl implements StudentIterator {

    private final List<Student> list;
    private int position = 0;

    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        return position < list.size();
    }

    @Override
    public Student next() {
        Student currentStudent = list.get(position);
        position++;
        return currentStudent;
    }
}
